layui.define(["table", "form"], function(e) {
    var admin = layui.admin;
    var $ = layui.$,
        form = layui.form,
        table = layui.table;
    //监听搜索
    form.on('submit(LAY-info-front-search)', function(data) {
        var field = data.field;
        //执行重载
       table.reload('LAY-info-manage', {
            where: field,
            page: {curr: 1},
        });
    });
    //事件
    var active = {
        batchdel: function() {},
         
    };
    $('.layui-btn.layuiadmin-btn-info').on('click', function() {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
    //表格内处理     
    table.render({
        elem: "#LAY-info-manage",
        url: app_url + "cashrar/listData",
        cols: [
            [  {
                field: "id",
                title: "ID",
                sort: !0,
                width:80,
            }, { 
                field: "username",
                title: "用户",
                width:120,
                height:120,
                align:'center',
                templet:'#userTpl',
               
            }, {
                field: "type_txt",
                title: "过帐类型",
               
            }, {
                field: "cash",
                title: "现金",
               
            }, {
                field: "money",
                title: "金币",
               
            }, {
                field: "create_time",
                title: "创建时间",
               
            }, {
                field: "check_flag_txt",
                title: "审核状态",
               
            }, {
                field: "pay_flag_txt",
                title: "支付状态",
               
            }, {
                title: "操作",
                align: "center",
                fixed: "right",
                toolbar: "#table-info-webuser"
            }]
        ],
        page: !0,
        limit: 10,
       height: "full-80",
        text: "对不起，加载出现异常！"
    }), table.on("tool(LAY-info-manage)", function(e) {
        if ("edit" === e.event) {
            var _data = e.data;
            let index = layer.open({
                type: 2,
                title: "编辑信息",
                content: app_url + "cashrar/edit?id=" + _data.id,
                maxmin: !0,
                area: ["500px", "450px"],
                btn: ["确定", "取消"],
                yes: function(e, t) {
                    var l = window["layui-layer-iframe" + e],
                        r = "LAY-info-front-submit",
                        n = t.find("iframe").contents().find("#" + r);
                    l.layui.form.on("submit(" + r + ")", function(t) {
                        var vals = [];
                        l.layui.$('select[name="cat_id"] option:selected').each(function() {
                            vals.push($(this).val());
                        });
                        t.field.cat_id = vals;
                        $.put(layui.setter.app_url + 'cashrar/update?id=' + _data.id, t.field, function(data, textStatus, xhr) {
                            if (data.status == 1) {
                                table.reload("LAY-info-manage"), layer.close(e)
                            }
                            layui.layer.msg(data.msg);
                        }, 'json');
                    }), n.trigger("click")
                },
                success: function(e, t) {}
            });
          
        }
    }), e("cashrar", {})
});